<#include "../common/layout/__mainlayout.html">
    <#include "../common/__pagination.html">

        <!--设置面包屑-->
        <#assign pageBreadCrumbs>
            <li class="active"><a href="#">广告管理</a></li>
            <li class="active">广告位管理</li>
        </#assign>
        <#assign pageCss>
            <!-- page specific plugin styles -->
            <link rel="stylesheet" href="${ctx}/static/admin/assets/css/jquery-ui.custom.css"/>
            <link rel="stylesheet" href="${ctx}/static/admin/assets/css/chosen.css"/>
            <link rel="stylesheet" href="${ctx}/static/admin/assets/css/datepicker.css"/>
            <link rel="stylesheet" href="${ctx}/static/admin/assets/css/daterangepicker.css"/>
        </#assign>

        <#assign pageJavascript>
            <script type="text/javascript">
                $(document).ready(function () {
                    $("#state").val(${query.state!});

                    $('[data-rel=tooltip]').tooltip();

                    if (!ace.vars['touch']) {
                        $('.chosen-select').chosen({allow_single_deselect: true});
                    }

                    // 清除远程modal数据
                    $("#editModal").on("hidden.bs.modal", function () {
                        $(this).removeData("bs.modal");
                    });

                    //初始化范围选择器
                    $('input[name=createDateRange]').daterangepicker({
                        'applyClass' : 'btn-sm btn-success',
                        'cancelClass' : 'btn-sm btn-default',
                        locale: {
                            applyLabel: '确定',
                            cancelLabel: '取消',
                        }
                    });



                    // 删除按钮
                    $("a.delete").on(ace.click_event, function (e) {
                        var currentA = this;
                        e.preventDefault();
                        bootbox.confirm({
                                    message: "确定删除该广告位?",
                                    buttons: {
                                        confirm: {
                                            label: "确定",
                                            className: "btn-primary btn-sm"
                                        },
                                        cancel: {
                                            label: "取消",
                                            className: "btn-sm"
                                        }
                                    },
                                    callback: function (result) {
                                        if (result){
                                            url = $(currentA).attr("href");
                                            $.get(url, { },function(data){
                                                if(data){
                                                    window.location.href=window.location.href;
                                                }
                                            });
                                        }
                                    }
                                }
                        );
                    });
                });
            </script>
        </#assign>

        <@mainlayout pageBreadCrumbs=pageBreadCrumbs pageCss=pageCss pageJavascript=pageJavascript currentMenu="adFlag-adSpaceFlag">
        <div class="row">
            <div class="col-xs-12">
            <form id="searchForm" class="form-search form-inline" action="/admin/ad/adSpaceList.do">
                <label>广告位编号:</label><input type="number" id="adSpaceId" name="adSpaceId" class="input-sm input-small"  max="99999999999" value="${query.adSpaceId!}"/>&nbsp;
                <label>广告位名称:</label><input type="text" id="adSpaceName" name="adSpaceName"  class="input-sm input-small" value="${query.adSpaceName!}"/>&nbsp;
                <select id="state" name="state" class="chosen-select input-md" data-placeholder="状态">
                    <option value="">--全部--</option>
                    <option value="0" >隐藏</option>
                    <option value="1"  >显示</option>
                    <option value="-1" >删除</option>
                </select>&nbsp;
                <label>创建时间:</label> <input class="form-control" type="text" class="input-sm input-small" value="${query.createDateRange!}"　 name="createDateRange" id="createDateRange"/>

                <input type="submit" id="searchBtn" class="btn btn-sm btn-primary" value="查询"/>&nbsp;
                <a href="${ctx}/admin/ad/viewAdSpace.do" class="btn btn-sm btn-warning" data-toggle="modal"
                   data-target="#editModal"><i class="ace-icon fa fa-plus"></i>添加</a>

            <table id="adSpaceTable" class="table table-striped table-bordered table-hover">
                <thead>
                <tr>
                    <th width="40" align="center">广告位编号</th>
                    <th width="100" align="left">广告位名称</th>
                    <th width="70" align="left">创建时间</th>
                    <th width="70" align="left">显示顺序</th>
                    <th width="60" align="left">状态</th>
                    <th width="30" align="center">展示终端</th>
                    <th width="80" align="center">图片宽度</th>
                    <th width="70" align="center">图片高度</th>
                    <th width="100" align="center">广告个数限制</th>
                    <th width="40" align="center">操作</th>
                </tr>
                </thead>
                <tbody>
                <#if adSpaceList.listData??>
                    <#list adSpaceList.listData as adSpace>
                    <tr>
                        <td>${adSpace.id!}</td>
                        <td>${adSpace.adSpaceName!}</td>
                        <td>
                            ${adSpace.createTimeShow!}
                        </td>
                        <td>${adSpace.sortIndex!}</td>
                        <td>
                            <#if adSpace.state == 0>
                                隐藏
                                <#elseif   adSpace.state = 1>
                                    显示
                                    <#elseif  adSpace.state = -1>
                                        删除
                                    <#else>
                            </#if>
                        </td>
                        <td>${adSpace.terminalId!}</td>
                        <td>${adSpace.picWidth!}</td>
                        <td>${adSpace.picHeight!}</td>
                        <td>${adSpace.adLimit!}</td>
                        <td>
                            <div class="hidden-sm hidden-xs action-buttons">
                                <a class="green tooltip-success edit" href="${ctx}/admin/ad/viewAdSpace.do?adSpaceId=${adSpace.id!}" data-rel="tooltip" title="修改" data-toggle="modal" data-target="#editModal"><span class="label label-success">修改</span></a>
                                <a class="green tooltip-success edit"  href="${ctx}/admin/ad/viewAdItem.do?origin=adSpaceList" class="tooltip"   data-rel="tooltip" title="新增内容" data-toggle="modal" data-target="#editModal">  <span class="label label-warning">新增内容</span></a>
                                <a class="red tooltip-error delete" href="${ctx}/admin/ad/deleteAdSpace.do?adSpaceId=${adSpace.id!}"   data-rel="tooltip" title="删除"> <span class="label label-danger">删除</span></a>
                            </div>

                            <div class="hidden-md hidden-lg">
                                <div class="inline position-relative">
                                    <button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown"  data-position="auto">
                                        <i class="ace-icon fa fa-caret-down icon-only bigger-120"></i>
                                    </button>
                                    <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                        <li><a href="${ctx}/admin/ad/viewAdSpace.do?adSpaceId=${adSpace.id!}" class="tooltip-success edit" data-rel="tooltip" title="编辑"   data-toggle="modal" data-target="#editModal"><span class="label label-success">修改</span></a>  </li>
                                        <li><a href="${ctx}/admin/ad/viewAdItem.do"  class="tooltip-success" data-rel="tooltip" title="新增内容"   data-toggle="modal" data-target="#editModal"> <span class="label label-warning">新增内容</span></a></li>
                                        <li><a href="${ctx}/admin/ad/viewAdSpace.do?adSpaceId=${adSpace.id!}"    class="tooltip-error delete" data-rel="tooltip" title="删除"> <span class="label label-danger">删除</span></a> </li>
                                    </ul>
                                </div>
                            </div>
                        </td>
                    </tr>
                </#list>
                </#if>
                </tbody>
            </table>
            <@pagination adSpaceList!/>
            </form>
        </div>
        </div>

        <div id="editModal" class="modal fade">
            <div class="modal-dialog">
                <div class="modal-content">
                </div>
            </div>
        </div>
    </@mainlayout>